<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %> 
<%@ page isELIgnored="false"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'aaa.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link rel="stylesheet" type="text/css"
			href="<%=path%>/js/extjs/resources/css/ext-all.css" />
		<script type="text/javascript"
			src="<%=path%>/js/extjs/adapter/ext/ext-base.js"></script>
		<script type="text/javascript" src="<%=path%>/js/extjs/ext-all.js"></script>
		<script type="text/javascript">
	
		
		Ext.onReady(function(){
		alert("iuiyu");
		
		var pgSize=5;   //=====提供每页显示记录数给分页控件
		
		//定义接收除了记录外的数据参数
		//var dataMeta2=new Object({
       // recordfrom: "from",
        //recordto: "to"
       // totalRecords: "count",    //=======提供总记录数给翻页控件     
       // });
		
		//定义记录映射规则
		//var itemRecord=new Ext.data.Record.create([
           // {name:'id',mapping:'id'},
           // {name:'name',mapping:'name'},
           // {name:'descript',mapping:'descript'},
           // {name:'itemcode',mapping:'itemcode'}]);
		
		//定义reader
		var itemReader=new Ext.data.JsonReader({
		     recordfrom: "from",
             recordto: "to"
             totalRecords: "count",    //=======提供总记录数给翻页控件     
		     root:'items',
		     fields:[
		       {name:'id',mapping:'id'},
               {name:'name',mapping:'name'},
               {name:'descript',mapping:'descript'},
               {name:'itemcode',mapping:'itemcode'}
		     ]
		
		
		});
		
		//定义proxy
		var itemProxy=new Ext.data.HttpProxy({
		          type:'ajax',
		          url:'getbookList.action'
		          });
		
		//定义数据源
		var itemStore=new Ext.data.Store({
             proxy:itemProxy,
             reader:itemReader
         });
		
		//定义顶部工具栏
		
		//定义底部分页工具栏
		
		 var sm = new Ext.grid.CheckboxSelectionModel();  
          //定义列模型
          var cm = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(), sm,  
        {header: "ID", width: 100, dataIndex: 'id', sortable: true},  
        {header: "菜品类别名字", width: 100, dataIndex: 'name', sortable: true},  
        {header: "菜品类别描述", width: 100, dataIndex: 'descript', sortable: true},  
        {header: "菜品类别编号", width: 100, dataIndex: 'itemcode', sortable: true}]);  


	
    var grid = new Ext.grid.GridPanel({
    title : '菜品类别列表', 
    frame:true, 
    store: itemStore,
    sm:sm,
    cm:cm,
    tbar : [{  
            xtype : 'tbtext',  
            text : '菜品类别查询'  
        }, {  
            xtype : 'textfield',  
            id : 'infoLinkman',  
            emptyText : '菜品类别',  
            width : 100  
        },{  
            xtype : 'button',  
            text : '查询',  
           handler:find  
        }], 
      bbar: new Ext.PagingToolbar({             //-======定义翻页控件
            pageSize:pgSize,                         // 参数1：每页显示数
            store: itemStore,                         // 数据源---非常重要
            displayInfo:true,
            displayMsg:'显示第{0}条数据到{1}条数据,一共有{2}条',
            emptyMsg:'没有记录'
        }) , 
    height:400,
    width:1200,
    renderTo: 'griddiv'
    });
    
    // -=====页面自动加载--并且忘后台传如分页信息
    itemStore.load({              
     params:{                       // =====分页参数
             start:0,                      // =====向后台提供 当前页码
             limit:pgSize                 // =====向后台提供 每页显示记录数
            }
    });


        
        
        
    
	}) ;	
	
	
	function find() {alert("查询");  }
		
		</script>

  </head>
  
  <body>
    添加新菜
    <form action="<%=path %>/itemdetailmgr/itemdetail.htm" method="post" enctype="multipart/form-data">
      菜品类别
      <select name="parentid">
         <option value="0" selected="selected">==请选择菜品类别==</option>
          <c:forEach var="litem" items="${lItems1}">
             <option value="${litem.id }">${litem.name }</option>
          </c:forEach>
      </select><br/>
      name <input type="text" name="name" value=""/><br/>
      descript <input type="text" name="descript" value=""/><br/>
       price<input type="text" name="price" value=""/><br/>
       discount<input type="text" name="discount" value=""/><br/>
       picture<input type="file" name="file_path1"/><br/>
       <input type="submit" value="添加"/>
    
    </form>
    
      <form action="<%=path %>/itemdetailmgr/itemdetail.img.htm" method="post" enctype="multipart/form-data">
       picture<input type="file" name="file_path1"/><br/>
       <input type="submit" value="添加"/>
    
    </form>
 
 
 <div id="griddiv"></div>
 
  </body>
</html>
